import java.rmi.*;
import java.rmi.server.*;


public class IncNumMessagesServer {
	public static void main(String args[]){
		System.out.println("Loading RMI Service IncreaseNumMessages");
		try{
			IncreaseNumMessagesImpl service = new IncreaseNumMessagesImpl();
			RemoteRef location = service.getRef();
			System.out.println(location.remoteToString());
			String registry ="localhost";
			
			if (args.length >=1){
				registry=args[0];
			}
			
			String registration = "rmi://" + registry + "/IncreaseNumMessages";
			Naming.rebind (registration, service);
			}
			catch(RemoteException re){
				System.err.println("Remote Error -" + re);
		}
		catch(Exception e){
			System.err.println("Error - " + e);
		}
	}
}
